/*
** main.c for RayTracer in /home/jeanma_d//Damien/Igraph/RayTracer/main.c
** 
** Made by damien jeanmaire
** Login   <jeanma_d@epitech.net>
** 
** Started on  Thu Feb  2 10:13:53 2012 damien jeanmaire
** Last update Thu Apr 26 17:03:20 2012 damien jeanmaire
*/

#include	"rt.h"

int		main(int ac, char **av)
{
  t_mlx		ptr;
  t_img		img;
  t_scene	sc;

  if (ac < 2)
    {
      my_putstr(USAGE);
      return (1);
    }
  init_cnf(av[1], &sc);
  if (!(ptr.mlx = mlx_init()))
    return (1);
  if (!(ptr.win = mlx_new_window(ptr.mlx, sc.size.x, sc.size.y, "Ray Tracer")))
    return (1);
  if (!(ptr.img = mlx_new_image(ptr.mlx, sc.size.x, sc.size.y)) ||
      !(img.data = mlx_get_data_addr(ptr.img, &(img.bpp),
				      &(img.szl), &(img.endi))))
    return (1);
  img.size = sc.size;
  fill_image(&ptr, &img, &sc);
  mlx_put_image_to_window(ptr.mlx, ptr.win, ptr.img, 0, 0);
  mlx_expose_hook(ptr.win, gere_expose, &ptr);
  mlx_key_hook(ptr.win, gere_key, 0);
  mlx_loop(ptr.mlx);
  return (0);
}
